package com.fr.cell.core;

import com.fr.base.Inter;
import com.fr.data.util.SortOrder;
import java.awt.Component;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JComboBox;
import javax.swing.JList;

public class SortOrderComboBox extends JComboBox
{
  DefaultListCellRenderer sortOrderCellRenderer;
  private static SortOrder[] SortOrderArray = { new SortOrder(1), new SortOrder(2), new SortOrder(0) };

  public SortOrderComboBox()
  {
    this(SortOrderArray);
  }

  public SortOrderComboBox(SortOrder[] paramArrayOfSortOrder)
  {
    this.sortOrderCellRenderer = new DefaultListCellRenderer(this)
    {
      private final SortOrderComboBox this$0;

      public Component getListCellRendererComponent(, Object paramObject, int paramInt, boolean paramBoolean1, boolean paramBoolean2)
      {
        super.getListCellRendererComponent(paramJList, paramObject, paramInt, paramBoolean1, paramBoolean2);
        if (paramObject instanceof SortOrder)
        {
          SortOrder localSortOrder = (SortOrder)paramObject;
          if (localSortOrder.getOrder() == 1)
            setText(Inter.getLocText("Sort-Ascending"));
          else if (localSortOrder.getOrder() == 2)
            setText(Inter.getLocText("Sort-Descending"));
          else if (localSortOrder.getOrder() == 0)
            setText(Inter.getLocText("Sort-Original"));
        }
        return this;
      }
    };
    setModel(new DefaultComboBoxModel(paramArrayOfSortOrder));
    setRenderer(this.sortOrderCellRenderer);
  }

  public SortOrder getSortOrder()
  {
    return ((SortOrder)getSelectedItem());
  }

  public void setSortOrder(SortOrder paramSortOrder)
  {
    GUICoreUtils.setSelectedItem(this, paramSortOrder);
  }
}